﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using AMatysiak.Methods;
using System;

namespace AMatysiakTest.Methods
{
    [TestClass]
    public class SubstringLastBeforeTest
    {
        private string text = "Zwolnijmy... Ale co? Ten galop";

        [TestMethod]
        public void emptyText()
        {
            string substr = text.SubstringLastBefore("");
            Assert.AreEqual("Zwolnijmy... Ale co? Ten galop", substr);
        }

        [TestMethod]
        public void toSecondWord()
        {
            string substr = text.SubstringLastBefore("...");
            Assert.AreEqual("Zwolnijmy", substr);
        }

        [TestMethod]
        public void toLastSpace()
        {
            string substr = text.SubstringLastBefore(" ");
            Assert.AreEqual("Zwolnijmy... Ale co? Ten", substr);
        }

        [TestMethod]
        public void toOneChar()
        {
            string substr = text.SubstringLastBefore("?");
            Assert.AreEqual("Zwolnijmy... Ale co", substr);
        }

        [TestMethod]
        public void oneLetter()
        {
            string substr = text.SubstringLastBefore("g");
            Assert.AreEqual("Zwolnijmy... Ale co? Ten ", substr);
        }

        [TestMethod]
        public void byNotExistingChar()
        {
            string substr = text.SubstringLastBefore("X");
            Assert.AreEqual("", substr);
        }

        [TestMethod]
        public void byFirstChar()
        {
            string substr = text.SubstringLastBefore("Z");
            Assert.AreEqual("", substr);
        }
    }
}
